/*
 * producer.c
 *
 *  Created on: Jun 20, 2009
 *      Author: jlapointe
 */
#include "producer.h"
#include "producer_consumer.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

void produce(request_list_container_t * list_container, char * data, request_t * outReq)
{
   pthread_mutex_lock(&(list_container->mutex));
   if (list_container->count >= list_container->max_length)
   {
      pthread_cond_wait(&(list_container->producerCond), &(list_container->mutex));
   }

   outReq->isValid = 1;
   outReq->isNullTerm = 0;
   outReq->req_length = sizeof(data);
   outReq->req = data;

   list_container->add(outReq);

   pthread_mutex_unlock(&(list_container->mutex));
   pthread_cond_signal(&(list_container->consumerCond));
}
